#include<bits/stdc++.h>

using namespace std;
const int maxn = 4;
char G[maxn][maxn] = {
        'A', 'B', 'C', 'D',
        'E', 'F', 'G', 'H',
        'I', 'J', 'K', 'L',
        'M', 'N', 'O', 'P'
};
bool book[maxn][maxn];
struct Node {
    int x, y;
};
int Next[][2] = {0, 1, 0, -1, 1, 0, -1, 0};

void dfs(int x, int y) {
    cout << G[x][y] << " ";
    book[x][y] = true;

    for (int i = 0; i < 4; i++) {
        int nx = x + Next[i][0];
        int ny = y + Next[i][1];
        if (nx < 0 || nx >= maxn || ny < 0 || ny >= maxn || book[nx][ny])continue;
        book[nx][ny] = true;
        dfs(nx, ny);
    }


}

int main() {
    dfs(0, 0);
    return 0;
}
